import React from "react";
import { Breadcrumb } from "antd";
import { Link } from "dva/router";
import Icon from "@cbd/icon";

import styles from "./TopBreadcrumb.less";

const routerName = {
  intellPush: "智能推送",
  applicationManager: "应用管理",
  recommendCenter: "推荐中心",
  dataSource: "数据源管理",
  dataSourceDetail: "数据源详情",
  addInfo: "新增",
  editInfo: "编辑",
  situation: "场景管理",
  addScene: "新增场景",
  editScene: "编辑场景",
  sceneDetail: "场景详情",
  plan: "计划管理",
  addPlan: "计划新增",
  editPlan: "计划编辑",
  planDetail: "计划详情",
  messagePic: "消息画像",
  messageFile: "消息档案",
  feedback: "反馈习惯",
  business: "业务管理",
  MonitorPush: "布控推送",

  systemManager: "系统管理",
  systemManage: "推送配置",
  systemMessage: "推送配置",
  sensitiveLog: "敏感日志",
  operateLog: "操作日志",
  backLog: "待办事项",

  messageCenter: "消息总线",
  messageManager: "消息管理",
  messageSource: "消息源管理",
  msgSourceManage: "消息源管理",
  myMessage: "我的消息",
  messageAdd: "发送任务注册",
  messageBacklog: "待办事项",
  interfaceLog: "接口日志",
  messageDetail: "消息详情",
  messageSend: "消息发送监控",
  channelManager: "消息渠道管理",
  channelList: "消息渠道列表",
  dingdingQun: "钉钉群列表",
  channelDetail: "渠道详情",
  // channelAdd: "渠道注册",
  labelManager: "标签列表",
  addLabel: "新增",
  editLabel: "编辑",
  labelDetail: "标签详情",
  myLabelManager: "我的标签",
  myAddLabel: "新增",
  myEditLabel: "编辑",
  myLabelDetail: "标签详情",

  supervisoryManager: "监控管理",
  supervisoryAdd: "监控",

  personalInfoMgt: "用户管理",
  userManagement: "个人信息管理",

  document: "帮助文档下载",
  channelNumber: "推送目标管理",
  edit: "渠道号编辑",
  channelRegister: "消息渠道注册",

  SMSmanagement: "短信配额管理",
  SMSquotaList: "短信配额列表",
  AddSMSquota: "短信配额配置",
  historyRecord: "历史配额",
  SMSstatistics: "短信统计概览",

  templateManager: "消息模板管理",
  templatelist: "消息模板列表",
  add: "新建消息模板",
  approveDetail: "审批详情页",

  AcceptGroup: "接收组管理",
  AcceptAdd: "新增接收组",
  msgSourceDetail: "消息源详情",
  msgSourceLogs: "消息源接收日志",
  tenantManage: "租户信息"
};

const routerLink = {
  applicationManager: "/intellPush/applicationManager",
  dataSource: "/intellPush/recommendCenter/dataSource",
  situation: "/intellPush/recommendCenter/situation",
  plan: "/intellPush/recommendCenter/plan",
  messagePic: "/intellPush/messagePic/messageFile",
  MonitorPush: "/intellPush/business/MonitorPush",
  // systemManage: "/systemManager/systemManage",
  backLog: "/systemManager/systemManage/backLog",
  messageSource: "/messageCenter/messageManager/messageSource",
  messageBacklog: "/systemManager/systemMessage/messageBacklog",
  interfaceLog: "/systemManager/systemMessage/interfaceLog",
  channelManager: "/messageCenter/channelManager/channelList",
  channelNumber: "/messageCenter/channelManager/channelNumber",
  edit: "/messageCenter/channelManager/channelNumber/edit",
  channelList: "/messageCenter/channelManager/channelList",
  dingdingQun: "/messageCenter/channelManager/dingdingQun",
  labelManager: "/messageCenter/channelManager/labelManager",
  myLabelManager: "/messageCenter/channelManager/myLabelManager",
  document: "/document",
  userManagement: "/messageCenter/personalInfoMgt/userManagement",

  SMSquotaList: "/messageCenter/SMSmanagement/SMSquotaList",
  SMSstatistics: "/messageCenter/SMSmanagement/SMSstatistics",

  supervisoryManager: "/messageCenter/supervisoryManager",

  templateManager: "/messageCenter/templateManager",
  add: "/messageCenter/templateManager/add",
  AcceptGroup: "/messageCenter/AcceptGroup/list",
  msgSourceManage: "/messageCenter/messageManager/msgSourceManage"
};

const TopBreadcrumb = ({ paths }) => {
  const pathSnippets = paths.split("/").filter(i => i);

  return (
    <div className={styles.root}>
      <Breadcrumb separator="/">
        {pathSnippets.map((item, index) => {
          const name = routerName[item];
          const link = routerLink[item];
          return (
            <Breadcrumb.Item
              key={item}
              style={{
                color:
                  index === pathSnippets.length - 1
                    ? "rgba(0,0,0,0.65)"
                    : "rgba(0,0,0,0.45)"
              }}
            >
              {link ? (
                <Link
                  to={link}
                  style={{
                    color:
                      index === pathSnippets.length - 1 || link
                        ? "rgba(0,0,0,0.65)"
                        : "rgba(0,0,0,0.45)"
                  }}
                >
                  {name}
                </Link>
              ) : (
                name
              )}
            </Breadcrumb.Item>
          );
        })}
        {/* <Icon type="renovate" /> */}
      </Breadcrumb>
      <div style={{ display: "flex", alignItems: "center" }}>
        <Icon
          type="renovate"
          className={styles.icon}
          onClick={() => {
            window.location.reload();
          }}
        />
      </div>
    </div>
  );
};

export default TopBreadcrumb;
